var e = require;
var t = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("NotifyEventType"),
    a = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("AudioManager"),
    s = e("ModuleUI"),
    l = e("CommonHelper"),
    c = e("UIManager"),
    d = e("sdkConfig"),
    h = e("AD"),
    _ = cc._decorator,
    u = _.ccclass,
    p = _.property,
    m = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.music_node = null),
                (t.sound_node = null),
                (t.shock_node = null),
                (t.privacy_btn = null),
                (t.give_up_btn = null),
                (t.side_btn = null),
                (t.side_node = null),
                (t.give_up_time = null),
                t
            );
        }
        return (
            __extends(t, e),

             (t.prototype.onDisable = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();

            }),

            (t.prototype.initView = function () {


                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();
                Adv_skd.default.instance.showGridAdLeft();
                Adv_skd.default.instance.showGridAdRight();
                Adv_skd.default.instance.showGridAdTop();
                Adv_skd.default.instance.showBannerAd();
                Adv_skd.default.instance.showInterstitialAd();

                if(cc.sys.platform==cc.sys.BYTEDANCE_GAME){
                    this.side_btn.active = true
                }else{
                    this.side_btn.active = false
                }
                e.prototype.initView.call(this),
                    (this.privacy_btn.active =
                        d.default.platform != d.EPlatform.TikTok && !a.GlobalParams.PlayerJoinFight),
                    (this.give_up_btn.active = a.GlobalParams.PlayerJoinFight),
                    this.showSettingInfo(),
                    this.give_up_btn.active && this.showGiveTime();
            }),
            (t.prototype.OnClick = function (t) {
                switch ((e.prototype.OnClick.call(this, t), t.node.name)) {
                    case "music_btn":
                        (a.GlobalParams.gameMusic.value = !a.GlobalParams.gameMusic.value),
                            a.GlobalParams.gameMusic.value ? r.default.playGameBGM() : r.default.stopMusic(),
                            this.showSettingInfo();
                        break;
                    case "sound_btn":
                        (a.GlobalParams.gameSound.value = !a.GlobalParams.gameSound.value), this.showSettingInfo();
                        break;
                    case "shake_btn":
                        (a.GlobalParams.gameShock.value = !a.GlobalParams.gameShock.value),
                            a.GlobalParams.gameShock.value && h.default.getInstance().vibrateShort(),
                            this.showSettingInfo();
                        break;
                    case "back_btn":
                        this.emitEvent(n.default.SEND_BOX_PORTAL_INFO, !0),
                            a.GlobalParams.PlayerJoinFight &&
                                d.default.platform == d.EPlatform.TikTok &&
                                h.default.getInstance().ResumeRecorder(),
                            this.node.destroy();
                        break;
                    case "privacy_btn":
                        cc.find("UIManager").getComponent(c.default).showPopup("privacy_view_ui");
                        break;
                    // case "side_btn":
                    //     let side = cc.instantiate(this.side_node);
                    //         side.parent = this.node;
                    //         side.active = true;
                    //     break;
                    case "give_up_btn":
                        cc
                            .find("Canvas")
                            .addChild(cc.instantiate(i.default.getInstance().getFightPrefab("give_up_view"))),
                            this.node.destroy();
                }
            }),
            (t.prototype.showSettingInfo = function () {
                (this.music_node.children[0].active = !a.GlobalParams.gameMusic.value),
                    (this.sound_node.children[0].active = !a.GlobalParams.gameSound.value),
                    (this.shock_node.children[0].active = !a.GlobalParams.gameShock.value),
                    (this.music_node.children[1].active = a.GlobalParams.gameMusic.value),
                    (this.sound_node.children[1].active = a.GlobalParams.gameSound.value),
                    (this.shock_node.children[1].active = a.GlobalParams.gameShock.value);
            }),
            (t.prototype.onclickSideBtn = function () {

                cc.resources.load("Side",cc.Prefab,(err,res)=>{
                    let side = cc.instantiate(res);
                    side.parent = this.node;
                    side.active = true;
                })
             
            }),
            (t.prototype.showGiveTime = function () {
                var e = this,
                    t = a.GlobalParams.GameGiveUpTime - new Date().getTime();
                t <= 0
                    ? ((this.give_up_time.node.active = !1),
                        (this.give_up_btn.getComponent(cc.Button).interactable = !0))
                    : ((this.give_up_time.string = l.default.getTimeStrByNum(t, !1, 2)),
                        (this.give_up_time.node.active = !0),
                        (this.give_up_btn.getComponent(cc.Button).interactable = !1),
                        this.scheduleOnce(function () {
                            e.showGiveTime();
                        }, 1));
            }),
            __decorate([p(cc.Node)], t.prototype, "music_node", void 0),
            __decorate([p(cc.Node)], t.prototype, "sound_node", void 0),
            __decorate([p(cc.Node)], t.prototype, "shock_node", void 0),
            __decorate([p(cc.Node)], t.prototype, "privacy_btn", void 0),
            __decorate([p(cc.Node)], t.prototype, "give_up_btn", void 0),
            __decorate([p(cc.Node)], t.prototype, "side_btn", void 0),
            __decorate([p(cc.Prefab)], t.prototype, "side_node", void 0),
            __decorate([p(cc.Label)], t.prototype, "give_up_time", void 0),
            __decorate([u], t)
        );
    })(s.default);
o.default = m;
